home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Scan header line. The R: has already been checked. *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen. All *)
- (* rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- FUNCTION scan_head(in_str : STRING;
- VAR calls_scanned : STRING;
- VAR dupe_cnt : WORD) : BOOLEAN;
-
- {$UNDEF DEBUG}
- {$UNDEF DEBUG_CS}
-
- VAR
-
- at_pos : BYTE;
- no_pos : BYTE;
-
- c : CHAR;
- code : INTEGER;
- i : INTEGER;
- j : INTEGER;
- l : LONGINT;
-
- new_time : LONGINT;
- num_msg : WORD;
-
- work_str : STRING[12];
- work_time : DATETIME;
-
- o_user : call_sign_str;
-
- t_bid : bid_str;
- t_flag : msg_flag_type;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Initialize and make sure we have the R: *)
- (*-----------------------------------------------------------------------*)
-
- scan_head := FALSE;
-
- IF NOT substr_compare(in_str, 1, 'R:') THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Initialize the reset *)
- (*-----------------------------------------------------------------------*)
-
- num_msg := 0;
-
- o_user := '';
-
- strip_crlf(in_str);
- upcase_str_var(in_str);
-
- (*-----------------------------------------------------------------------*)
- (* Handle some stupid errors *)
- (*-----------------------------------------------------------------------*)
-
- IF (in_str[4] = '0') OR (in_str[4] = '1') THEN
- BEGIN;
- IF substr_compare(in_str, 3, '000') OR
- substr_compare(in_str, 3, '800') OR
- substr_compare(in_str, 3, '810') THEN
- in_str := 'R:880101/0001' + substr(in_str, 14, 0);
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Convert the year. If not valid, quit *)
- (*-----------------------------------------------------------------------*)
-
- VAL(SUBSTR(in_str, 3, 2), i, code);
-
- IF (code <> 0) OR (i < 88) THEN
- EXIT;
-
- work_time.year := i + 1900;
-
- {$IFDEF DEBUG}
- WRITELN('Year = ', work_time.year);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Convert the month. If not valid, quit *)
- (*-----------------------------------------------------------------------*)
-
- VAL(SUBSTR(in_str, 5, 2), i, code);
- IF (code <> 0) OR (i < 1) OR (i > 12) THEN
- EXIT;
-
- work_time.month := i;
-
- {$IFDEF DEBUG}
- WRITELN('Month = ', work_time.month);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Convert the day. If not valid, quit *)
- (*-----------------------------------------------------------------------*)
-
- VAL(SUBSTR(in_str, 7, 2), i, code);
- IF (code <> 0) OR (i < 1) OR (i > 31) THEN
- EXIT;
-
- work_time.day := i;
-
- {$IFDEF DEBUG}
- WRITELN('Day = ', i);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Verify the date/time break *)
- (*-----------------------------------------------------------------------*)
-
- IF in_str[9] <> '/' THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Convert the hour. If not valid, quit *)
- (*-----------------------------------------------------------------------*)
-
- VAL(SUBSTR(in_str, 10, 2), i, code);
- IF (code <> 0) OR (i < 0) OR (i > 24) THEN
- EXIT;
-
- work_time.hour := i;
-
- {$IFDEF DEBUG}
- WRITELN('Hour = ', i);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Convert the minutes. If not valid, quit *)
- (*-----------------------------------------------------------------------*)
-
- VAL(SUBSTR(in_str, 12, 2), i, code);
- IF (code <> 0) OR (i < 0) OR (i > 59) THEN
- EXIT;
-
- work_time.min := i;
-
- {$IFDEF DEBUG}
- WRITELN('Min = ', i);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Set the seconds to zero and convert to internal format *)
- (*-----------------------------------------------------------------------*)
-
- work_time.sec := 0;
-
- convert_time(work_time, new_time);
-
- (*-----------------------------------------------------------------------*)
- (* Find the "@" symbol. Must have one *)
- (*-----------------------------------------------------------------------*)
-
- at_pos := POS('@', in_str);
-
- IF at_pos = 0 THEN EXIT;
-
- {$IFDEF DEBUG}
- WRITELN('ATPOS = ', at_pos);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Process the incoming BID info *)
- (*-----------------------------------------------------------------------*)
-
- t_bid := '';
-
- no_pos := POS(' $:', in_str);
-
- IF (no_pos <> 0)
- AND ((LENGTH(in_str) - 3) > no_pos)
- AND ((active_tcb^.curr_msg.msg_i_mb.msg_flag AND mf_bid_change) = 0)
- AND (no_pos > 1) THEN
- BEGIN;
-
- work_str := COPY(in_str, no_pos + 3, 255);
- work_str := subword(@work_str, 1, 1);
-
- IF LENGTH(work_str) < SIZEOF(t_bid) THEN
- t_bid := work_str;
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Find the "#:" symbol. If there is one, it's the NK6K format *)
- (* If not, it's the WA7MBL/KA2BQE format. Convert the message number *)
- (*-----------------------------------------------------------------------*)
-
- no_pos := POS('#:', in_str);
-
- IF no_pos <> 0 THEN
- BEGIN;
-
- {$IFDEF DEBUG}
- WRITELN('NOPOS = ', no_pos);
- {$ENDIF}
-
- (*-------------------------------------------------------------------*)
- (* Convert message number from NK6K Format *)
- (*-------------------------------------------------------------------*)
-
- IF LENGTH(in_str) > no_pos THEN
- INC(no_pos, 2);
-
- work_str := COPY(in_str, no_pos, 255);
- work_str := subword(@work_str, 1, 1);
- VAL(work_str, l, code);
-
- END
- ELSE
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Convert message number from MBL Format *)
- (*-------------------------------------------------------------------*)
-
- i := 15; (* Magic number pick by analysis of header *)
-
- WHILE (i <= LENGTH(in_str)) AND (in_str[i] = ' ') DO
- INC(i);
-
- IF i >= LENGTH(in_str) THEN
- EXIT;
-
- {$IFDEF DEBUG}
- WRITELN('MBL ', i, ' ', at_pos, ' = ', in_str);
- {$ENDIF}
-
- j := at_pos - i;
-
- (*-------------------------------------------------------------------*)
- (* Number is too long.. Leave *)
- (*-------------------------------------------------------------------*)
-
- IF (j > 7) THEN
- EXIT;
-
- (*-------------------------------------------------------------------*)
- (* If a message number is present then convert it else randomize it *)
- (* This is for the darn THEBOX people who insist on no # *)
- (*-------------------------------------------------------------------*)
-
- IF j >= 1 THEN
- BEGIN;
- work_str := COPY(in_str, i, j);
- VAL(work_str, l, code);
- END
- ELSE
- BEGIN;
- l := RANDOM(32767) + 1;
- code := 0;
- END;
-
- END;
-
- {$IFDEF DEBUG}
- WRITELN('NO = ', code, '/', l);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* If we don't have a valid number then leave *)
- (*-----------------------------------------------------------------------*)
-
- IF (code <> 0) OR (l < 1) OR (l > 9999999) THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Make sure number is within range *)
- (*-----------------------------------------------------------------------*)
-
- num_msg := l AND $FFFF;
-
- (*-----------------------------------------------------------------------*)
- (* Now we will locate the originating BBS and validate it. *)
- (*-----------------------------------------------------------------------*)
-
- IF in_str[at_pos + 1] = ':' THEN
- at_pos := at_pos + 2
- ELSE
- INC(at_pos);
-
- in_str := COPY(in_str, at_pos, 255);
- in_str := subword(@in_str, 1, 1);
-
- {$IFDEF DEBUG}
- WRITELN('ATPOS = ', at_pos);
- DELAY(1000);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Scan forward for a non-alphameric that ends the call *)
- (*-----------------------------------------------------------------------*)
-
- i := 0;
- REPEAT
- INC(i);
- IF i <= LENGTH(in_str) THEN
- c := in_str[i]
- ELSE
- c := ' ';
- UNTIL ((c < 'A') OR (c > 'Z'))
- AND ((c < '0') OR (c > '9'));
-
- IF i > 0 THEN
- work_str := COPY(in_str, 1, i-1);
-
- {$IFDEF DEBUG_CS}
- WRITELN('CALL = ', i, ' = ', work_str);
- {$ENDIF}
-
- IF (i > SIZEOF(bb_addr_str)) OR (i < 3) THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Now see if the call has a hierarchical address attached.... *)
- (* Note that an invalid hierarchcial address will not terminate the *)
- (* header scan *)
- (*-----------------------------------------------------------------------*)
-
- IF c <> '.' THEN
- in_str := ''
- ELSE
- BEGIN;
-
- INC(i);
- in_str := COPY(in_str, i, 255);
-
- REPEAT
- INC(i);
- IF i <= LENGTH(in_str) THEN
- c := in_str[i]
- ELSE
- c := ' ';
- UNTIL ((c < 'A') OR (c > 'Z'))
- AND ((c < '0') OR (c > '9'))
- AND (c <> '.')
- AND (c <> '#');
-
- IF (i > 0) AND (i <= SIZEOF(h_addr_str)) THEN
- in_str := COPY(in_str, 1, i-1)
- ELSE
- in_str := '';
-
- END;
-
- {$IFDEF DEBUG}
- WRITELN('CALL = ', i, ' = ', in_str);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* If we got here, the the header parsed ok. Set the message data *)
- (*-----------------------------------------------------------------------*)
-
- active_tcb^.curr_msg.msg_i_mb.msg_from_at := work_str;
- active_tcb^.curr_msg.msg_i_mb.msg_from_h := in_str;
- active_tcb^.curr_msg.msg_i_mb.msg_dt_orig := new_time;
- active_tcb^.curr_msg.msg_i_mb.msg_no_orig := num_msg;
-
- IF (t_bid <> '')
- AND ((active_tcb^.curr_msg.msg_i_mb.msg_flag
- AND (mf_bid_change OR mf_bid_override)) = 0) THEN
- BEGIN;
- active_tcb^.curr_msg.msg_i_mb.msg_bid := t_bid;
- active_tcb^.curr_msg.msg_i_mb.msg_flag :=
- active_tcb^.curr_msg.msg_i_mb.msg_flag OR mf_bid_override;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Save this call so we can post the route list *)
- (*-----------------------------------------------------------------------*)
-
- IF (LENGTH(calls_scanned) + LENGTH(work_str) + 1) <= 255 THEN
- calls_scanned := calls_scanned + ' ' + work_str;
-
- {$IFDEF DEBUG_CS}
- WRITELN('CScan=', LENGTH(calls_scanned), '=', calls_scanned);
- WRITELN('CWork=', LENGTH(work_str), '=', work_str);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* See if we should hold on a possible loop *)
- (*-----------------------------------------------------------------------*)
-
- IF compare_call(active_tcb^.curr_msg.msg_i_mb.msg_from_at,
- opt_block.this_bb_addr) THEN
- BEGIN;
-
- INC(dupe_cnt);
- t_flag := active_tcb^.curr_msg.msg_i_mb.msg_flag;
-
- IF (dupe_cnt = opt_block.hold_dupe_hdr)
- AND ((t_flag AND mf_hold) = 0) THEN
- BEGIN;
- active_tcb^.curr_msg.msg_i_mb.msg_flag := t_flag OR mf_hold;
- active_tcb^.curr_msg.msg_i_mb.msg_reason := message_reason_loop;
- send_message(message_reason_loop);
- END;
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* It worked! *)
- (*-----------------------------------------------------------------------*)
-
- {$IFDEF DEBUG}
- WRITELN('TRUE EXIT');
- {$ENDIF}
-
- scan_head := TRUE;
-
- END; (*----- End scan head proc -------------------------------------------*)